#!/usr/bin/python3
'''
@Author  :   宏宇
@Time    :  2022/4/26 15:39
@Desc    :
'''

import os
import sys

import click

sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'utils'))
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'service'))

from data import Data
from dictation import Dictation


@click.group()
def cli():
    click.echo("")


@cli.command()
@click.argument('name')
def one_unit(name):
    '''指定单词集进行默写'''
    file_path = Data.get_file_path_by_name(name)
    if file_path is None:
        return
    data = Data.get_one_file_data(file_path)
    new_dic = Data.random_dic(data)
    Dictation.chinese_to_english(new_dic)


@cli.command()
@click.option('--count', '-c', default=99999, type=int)
def mixed(count):
    '''打乱所有的单词进行默写'''
    data = Data.get_all_word()
    new_dic = Data.random_dic(data, count)
    Dictation.chinese_to_english(new_dic)



@cli.command()
def error():
    '''复习错误单词'''
    data = Data.get_error_word()
    if data is None:
        return
    new_dic = Data.random_dic(data)
    Dictation.chinese_to_english(new_dic)









if __name__ == '__main__':
    cli()
